package ioc

import (
	"github.com/gin-gonic/gin"
	"google.golang.org/grpc"
)

var container *Container

func init() {
	container = &Container{
		services:    make(map[string]IocObj, 0),
		controllers: make(map[string]CIocObj, 0),
		apis:        make(map[string]ApiIocObj, 0),
		grpcs:       make(map[string]GrpcIocObj, 0),
	}
}

// api类
type ApiIocObj interface {
	CIocObj
	Register(r gin.IRouter)
}

type GrpcIocObj interface {
	CIocObj
	Register(s *grpc.Server)
}

// 控制器结构体
type CIocObj interface {
	Init() error
	IocObj
}

// 通用结构体
type IocObj interface {
	Name() string
}

type Container struct {
	services    map[string]IocObj
	controllers map[string]CIocObj
	apis        map[string]ApiIocObj
	grpcs       map[string]GrpcIocObj
}

func App() *Container {
	return container
}
